$(function () {
    var E = window.wangEditor;
    var editor = new E('#ueditor');
    editor.customConfig.menus = [
        'head',
        'bold',
        'italic',
        'underline',
        'fontName',
        'strikeThrough',
        'foreColor',
        'backColor',
        'undo',
        'redo'
    ];
    editor.create();
    // 发表评论
    $('.public-btn').on('click',function (event) {
        console.log(111);
        var is_login = $('#is-login').attr('data-login');
        if (!is_login) {
            window.location.href = '/signin/'
        }else{
            var article_id = $(this).attr('data-article-id');
            var content = editor.txt.html();
            juneajax.post({
                'url': '/add_comment/',
                'data': {
                    'content': content,
                    'article_id': article_id
                },
                'success': function (data) {
                    if (data['code']==200) {
                        window.location.reload()
                    }else{
                        junealert.alertErrorToast(data['message'])
                    }
                },
                'fail': function (error) {
                    junealert.alertNetworkError()
                }
            })
        }
    })
});
